package com.moyou.weichat.listener;

import android.util.Log;

import com.hyphenate.EMConnectionListener;
import com.hyphenate.EMError;
import com.moyou.weichat.WeiChatApplication;
import com.moyou.weichat.utils.ConstantUtils;
import com.moyou.weichat.utils.T;

/**
 * Created by Administrator on 2017/11/7 0007.
 * sj： 2017年11月7日14:20:29
 * name: ts
 * 用途： 监听环信的链接异常
 */

public class ChatEMConnectionListener implements EMConnectionListener {
    private ChatConnctionUIHandler chatConnctionUIHandler ;

    public ChatEMConnectionListener(ChatConnctionUIHandler chatConnctionUIHandler) {
        this.chatConnctionUIHandler = chatConnctionUIHandler;
    }

    @Override
    public void onConnected() {
        //正在链接
        chatConnctionUIHandler.sendEmptyMessage(ConstantUtils.TYPE_NUMBER_ONE);
    }

    @Override
    public void onDisconnected(int error) {

        //断开链接
        if (error == EMError.USER_REMOVED || error == EMError.USER_LOGIN_ANOTHER_DEVICE || error == EMError.SERVER_SERVICE_RESTRICTED
                || error == EMError.USER_KICKED_BY_CHANGE_PASSWORD || error == EMError.USER_KICKED_BY_OTHER_DEVICE) {
//            isConflict = true;
        } else {
            chatConnctionUIHandler.sendEmptyMessage(ConstantUtils.TYPE_NUMBER);
        }
    }
}
